<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        function SuperType(name){
            this.name=name;
            this.colors=["red","blue","yellow"];

        }
        SuperType.prototype.SayName=function(){
           alert(this.name);
        } 
        var instance=new SuperType("jjjjj");
        instance.colors.push("black123");
        alert(instance.colors);
        instance.SayName();


        function SubType(name,age){
            SuperType.call(this,name);
            this.age=age;
        }

        //继承方法
        SubType.prototype=new SuperType();
        // SubType.prototype.constructor=SubType;
        SubType.prototype.SayAge=function(){
            alert(this.age)
        };

       

        var instance1=new SubType("job",22);
        instance1.colors.push("black");
        alert(instance1.colors);
        instance1.SayAge();
        instance1.SayName()


        var instance2=new SubType("joob",222);
        alert(instance2.colors);
        instance2.SayAge();
        instance2.SayName()


    </script>
</head>
<body>
    
</body>
</html>